<!DOCTYPE html>
<html>
{include file='public/header'}
<style>
    .layui-input-block{
        margin-left: 100px;
    }
</style>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">财务中心</a>
            <a><cite>广告金列表</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <form class="layui-form" lay-filter="searchForm" id="handle-form">
            <div class="layui-inline">
                <label class="layui-form-label w-auto">时间：</label>
                <div class="layui-inline" id="time" style="display: flex;align-items: center;">
                    <div class="layui-input-inline" style="margin-right:10px">
                        <input type="text" class="layui-input" name="start_date" id="start_date" autocomplete="off" placeholder="开始时间">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="end_date" id="end_date" autocomplete="off" placeholder="结束日期">
                    </div>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label w-auto">小程序：</label>
                <div id="pMenu"></div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label w-auto">主体：</label>
                <div id="companyMenu"></div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
                <button type="button" id="leading-out" class="layui-btn ">导出全部数据</button>
            </div>
        </form>
        <table id="adFunds"  lay-filter="adFunds"></table>
    </div>

    <script>
        let totalObj = {}
        let params = {
            elem: '#adFunds'
            , toolbar: true
            , url: '/admin/finance/adFunds' //数据接口
            , id: 'adFunds'
            , limit:10
            , page:true
            , cols: [[ //表头
                // { field: 'id', title: 'ID', align: 'center', width:250}
                 { title: '时间周期', align:'center' , width:250, templet:function(d){
                    return `${d.start_query_date}至${d.end_query_date}`
                }}
                , { title: '结算周期', align:'center' , width:250, templet:function(d){
                    return `${d.start_date}至${d.end_date}`
                }}
                , { field: 'applet_name', title: '小程序', width:250, align:'center' }
                , { field: 'company_name', title: '主体', width:250, align:'center' }
                , { field: 'price', title: '充值', width:250, align:'center' }
                , { field: 'refund_price', title: '退款', width:250, align:'center' }
                , { field: 'tx_ad_price', title: '腾迅广告激励金', width:200, align:'center' }
                
            ]],
        }
        tableList(params) 
        layui.use(['table','laydate'], function () {
            var table = layui.table;
            

            var laydate = layui.laydate
            // 日期
            laydate.render({
                elem: '#time',
                range: ['#start_date', '#end_date'],
                format: 'yyyy-MM-dd'
            });
        });

        $("#leading-out").click(function() {
            var data = $('#handle-form').serialize();
            derive('/admin/finance/exportAdFunds',data)
        });

        let selectParams = {
            url: '/admin/finance/appletList',
            elem: '#pMenu',
            selected: [],
            tips: '选择小程序',
            name: 'applet_id',
            field_id: 'id',
            field_Name: 'name',
        }
        selectN(selectParams)

        let selectCompanyParams = {
            url: '/admin/company/select',
            elem: '#companyMenu',
            selected: [],
            tips: '选择公司',
            name: 'company_id',
            field_id: 'id',
            field_Name: 'name',
        }
        selectN(selectCompanyParams)
    </script>
</body>

</html>